package com.hd.trans.share;

import android.app.Activity;
import android.app.Application;

import java.io.File;

public class ShareTextFileManager {
    private final Activity activity;
    private ShareManagerModel shareMg;

    @Deprecated
    public ShareTextFileManager(Application application, Activity activity) {
        this(activity);
    }
    public ShareTextFileManager(Activity activity) {
        this.activity = activity;
    }

    public void shareTextFile(String content, String name, int enShareFileType) {
        shareTextFile(content, name, null, enShareFileType);
    }

    public void shareTextFile(String content, String name, String language, int enShareFileType) {
        if (null == shareMg) {
            shareMg = new ShareManagerModel();
        }
        if (enShareFileType == EnShareFileType.TXT_FILE) {
            //创建一个文件
            File file = new File(activity.getExternalCacheDir(), name + ".txt");
            //把文本写进文件，并分享
            shareMg.shareTxt(activity, content, file);
        } else if (enShareFileType == EnShareFileType.SRT_FILE) {
            //创建一个文件
            File file = new File(activity.getExternalCacheDir(), name + ".srt");
            //把文本写进文件，并分享
            shareMg.shareTxt(activity, content, file);
        } else {
            shareMg.sharePdfWord(activity, content, language, enShareFileType, name);
        }
    }
}
